/**
 * 导航栏
 */

const IT_BASE_URL = '/10.知识管理/01.IT'


const IT_URL_Arr = [
    {
        text: "前端",
        link: "/02.server/知识点/mysql.html",
        children: [
            {
                text: "前端总结",
                link: "/01.web/js总结.html",
            },
            {
                text: "文档链接",
                children: [
                    { text: "vue2.0", link: "https://v2.cn.vuejs.org/v2/guide/instance.html" },
                    { text: "vue3.0", link: "https://cn.vuejs.org/guide/quick-start.html" },
                    { text: "Element ui", link: "https://element.eleme.cn/#/zh-CN/component/installation" },
                    { text: "Element plus ", link: "https://element-plus.gitee.io/zh-CN/component/button.html" },
                    { text: "Arco design", link: "https://arco.design/vue/docs/start" },
                    { text: "swiper轮播", link: "https://www.swiper.com.cn/index.html" },
                    { text: "web3.0", link: "https://web3.tryblockchain.org/web3-js-in-action.html" },
                    { text: "vuePress", link: "https://vuepress.vuejs.org/zh" },
                ],
            },
            {
                text: "小程序",
                children: [
                    { text: "微信开放文档", link: "https://developers.weixin.qq.com/miniprogram/dev/framework/" },
                    { text: "uniapp", link: "https://uniapp.dcloud.net.cn/component/" },
                    { text: "uView", link: "https://www.uviewui.com/components/intro.html" },
                ],
            },
            {
                text: "统计图",
                children: [
                    { text: "echarts", link: "https://echarts.apache.org/examples/zh/index.html" },
                    { text: "社区makeapie", link: "https://www.makeapie.cn/echarts" },
                    { text: "社区isqqw", link: "https://www.isqqw.com/homepage" },
                    { text: "社区PPChart", link: "http://ppchart.com/#/" },
                    { text: "社区analysis", link: "http://chartlib.datains.cn" },
                ],
            },

            {
                text: "CDN",
                children: [
                    { text: "bootCdn", link: "https://www.bootcdn.cn/" },
                    { text: "jsdelivr", link: "https://www.jsdelivr.com/" }
                ],
            },
        ],
    },
    {
        text: "java",
        link: "/02.server/知识点/jvm.html",
        children: [
            { text: "jvm", link: "/02.server/知识点/jvm.html" },
            { text: "并发", link: "/02.server/并发/JMM.html" }
        ],
    },
    {
        text: "框架",
        children: [
            { text: "mybatis", link: "/02.server/mybatis/mybatis语法.html" },
            { text: "mybatis plus", link: "https://baomidou.com/pages/24112f/" },
            { text: "spring boot", link: "/02.server/知识点/springBoot.html" },
            { text: "spring cloud alibaba", link: "/02.server/springCloudAlibaba/spring cloud alibaba.html" },
        ],
    },
    {
        text: "数据库",
        children: [
            { text: "mysql", link: "/02.server/知识点/mysql.html" },
            { text: "mysql8.0特性", link: "/02.server/mysql/mysql8.0特性.html" },
            { text: "Sharding-jdbc", link: "/02.server/mysql/sharding-jdbc.html" },
            { text: "Canal", link: "/02.server/mysql/canal.html" },
        ],
    },
    {
        text: "中间件",
        children: [
            { text: "redis", link: "/02.server/redis/redis.html" },
            { text: "消息队列", link: "/02.server/消息队列/消息队列.html" },
        ],
    },
    {
        text: "运维",
        link: "/03.operation/快速部署.html",
    },


]


export default urlMap();


function urlMap() {

    var totalUrlArr = [
        {
            text: "首页",
            link: "/",
        }
    ]


    // IT 类
    handleUrlMap(totalUrlArr, IT_BASE_URL, IT_URL_Arr)

    // console.log("navbar: " , totalUrlArr)
    return totalUrlArr;
}


/*********************  处理中文路径匹配-开始 ***********************************/

function handleUrlMap(totalUrlArr, baseUrl, IT_URL_Arr) {
    handlerUrlList(baseUrl, IT_URL_Arr)
    totalUrlArr.push(...IT_URL_Arr)
}

function handlerUrlList(baseUrl, urlList) {
    urlList.forEach(item =>{
        if (item.link) {
            item.link = handleUrl(baseUrl, item.link)
        }
        if (item.children) {
            handlerUrlList(baseUrl, item.children)
        }
    })
}

function handleUrl(baseUrl, url){
    if (/(http|https):\/\/\S*/.test(url)){
        return url
    }
    return encodeURI(baseUrl + url)
}


/*********************  处理中文路径匹配-结束 ***********************************/
